#ifndef REAL_TIME_WINDOW_H
#define REAL_TIME_WINDOW_H

#include <gtkmm.h>
#include <ImageType.hpp>
#include <array>
#include <string>
#include <mutex>
#include <atomic>

class RealTimeWindow
{
  public:
    RealTimeWindow(const std::string& projectname,const std::string & taskname);
    virtual ~RealTimeWindow();
    void Show();
    void ShowOriginImage(const ImageType& data,int index);
    void ShowImageSingle(const ImageType & data);
    void on_startShot_click(const sigc::slot<void(Gtk::Button*)>& slot);
    void test_call(Glib::RefPtr<Gtk::Application> app);
    std::function<void()> funcWindowsCloseCallback;
    std::function<void(bool)> funcRecordCallback;
  private:
    Glib::RefPtr<Gtk::Builder> UIbuilder;
    Gtk::Window* pWindow;
    Gtk::Button* btnShotControl;
    Gtk::Label* labInfo;
    std::array<Gtk::DrawingArea*,5> monitorAllList;
    std::array<Glib::RefPtr<Gdk::Pixbuf>,5> originImageList;
    std::array<std::mutex,5> originImageMutList;
    std::array<std::atomic_bool,5> refreshOriginImageList;
    bool onShotControl=false;
    void on_btnShowControl_click();

    Gtk::DrawingArea* monitorSingle;
    std::mutex mutSingle;
    Glib::RefPtr<Gdk::Pixbuf> singleImage;

    void on_notification_from_work_thread();
    Glib::Dispatcher m_dispatcher;
    bool refreshFlag=false;

    void on_draw(const Cairo::RefPtr<Cairo::Context>& cr,int width,int height,int index);
    void on_draw_singleImage(const Cairo::RefPtr<Cairo::Context>& cr, int width,int height);
};

#endif
